Ext.define('Jee.Ajax', {
    singleton: true,
    autoAbort : false,
    request : function(jeeRequest,config) {
	    config = config ||{};
	    var maskTarget = Ext.getBody();
	    if(config.maskTarget){
	    	maskTarget = config.maskTarget;
	    }
	    var mask = new Ext.LoadMask(maskTarget, {
	        msg : '正在加载...',
	        removeMask : true 
	    });
	   
	    Ext.apply(config,{  
	    	url : 'json/',  
			method : 'POST',  
			timeout : 60000,
			success : function(form, action) {
	    	   mask.hide();
	    	   var result = Ext.decode(form.responseText);
               if(result.successFlag){
            	    if(config.successCallback){
            	    	config.successCallback(result.data);
            	    }
               }else{
            	    var msg = '操作失败';
            	    if(result.msg){
            	    	msg = result.msg;
            	    }
            	    if(config.failCallback){
            	    	config.failCallback(result);
            	    }else{
	            	    Ext.MessageBox.show({
	            		   width:150,
	            		   title:"错误",
	            		   buttons: Ext.MessageBox.OK,
	            		   msg:msg
	        		   });
            	    }  
               }
			},
			failure : function(form, action) { 
				  mask.hide();
            	  Ext.MessageBox.show({
                		   width:150,
                		   title:"错误",
                		   buttons: Ext.MessageBox.OK,
                		   msg:'系统错误'
            	  });
			}
	    });
	    mask.show();
	    config.jsonData = jeeRequest;
	    return Ext.Ajax.request(config);
    }
});